<?php

namespace LowCode\UI;

use LowCode\Support\JsExp;
use LowCode\Traits\HasDeprecatedChildren;

class AnalysisOverview extends Node
{
    use HasDeprecatedChildren;

    /**
     * @param string $title
     * @param int $value
     * @param string|null $totalTitle
     * @param int|null $totalValue
     * @param string|null $icon
     * @return $this
     */
    public function item(string $title, int $value, string $totalTitle = null, int $totalValue = null, string $icon = null): static
    {
        $props = $this->props??[];
        $items = $props['items']??[];
        $items[] = compact('title','value','totalTitle', 'totalValue','icon');
        return $this->items($items);
    }

    /**
     * @param array|JsExp $items
     * @return $this
     */
    public function items(array|JsExp $items): static
    {
        return $this->prop("items",$items);
    }
}
